package com.lifa.controller;

import com.lifa.dao.HuiYuanLeiXingDao;
import com.lifa.entity.HuiyuanChongzhi;
import com.lifa.entity.Huiyuanleixing;
import com.lifa.service.HuiYuanLeiXingService;
import org.apache.commons.fileupload.util.LimitedInputStream;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/huiyuanleixing")
@Scope("prototype")
public class HuiYangLeiXingController {
    @Autowired
    private HuiYuanLeiXingService huiYuanLeiXingService;
    @Autowired
    private HuiYuanLeiXingDao huiYuanLeiXingDao;

    //绑定下拉框
    @RequestMapping("/chax")
    @ResponseBody
    public List<Huiyuanleixing> chax(){
        return huiYuanLeiXingDao.chax();
    }

    @RequestMapping("/chax1")
    @ResponseBody
    public List<Huiyuanleixing> chax1(){
        return huiYuanLeiXingService.chax1();
    }

    @RequestMapping("/fenye1")
    @ResponseBody
    public Map<String,Object> fenye1(String username,int offset,int limit){
        Map<String,Object> map=new HashMap<>();
        map.put("rows",huiYuanLeiXingService.fenye1(username,offset,limit));
        map.put("total",huiYuanLeiXingService.zongtiaoshu1(username));
        return map;
    }
    @RequestMapping("/tianjia1")
    @ResponseBody
    public int tianjia1(Huiyuanleixing huiyuanleixing){
        return huiYuanLeiXingService.tianjia1(huiyuanleixing);
    }

    @RequestMapping("/sc1")
    @ResponseBody
    public int sc1(int huiyuanleixing_Id){
        return huiYuanLeiXingService.sc1(huiyuanleixing_Id);
    }

    @RequestMapping("/xgai1")
    @ResponseBody
    public int xgai1(Huiyuanleixing huiyuanleixing){
//        System.out.println(huiyuanleixing.getHuiyuanleixing_Id()+"---");
        return huiYuanLeiXingService.xgai1(huiyuanleixing);
    }

    @RequestMapping("/xgaiid")
    @ResponseBody
    public Huiyuanleixing  xgaiid(int huiyuanleixing_Id){
        return huiYuanLeiXingService.xgaiid1(huiyuanleixing_Id);
    }

}
